package com.search.service;

import com.alibaba.fastjson2.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class CapitalShelfNoSearch {

    public static void main(String[] args) {
        CapitalShelfNoSearch search = new CapitalShelfNoSearch();
        search.thirdSearch("https://primo.clcn.net.cn/primo_library/libweb/action/expand.do?fn=expend&id=STL0100171008413286932964113457064569210903710&ilsApiId=STL01001710084&mainLocation=ST001&callNumber=A121+%2f7&secondaryLocation=ST02&holdingRecordID=&linkIndex=13&recIds=CLCN_ALEPH_CN001710084&recIdxs=0&elementId=exlidResult0-TabContainer&renderMode=prefetchXml&displayMode=brief&tabs=locationsTab&startPosition=1&https://primo.clcn.net.cn:443/primo_library/libweb/action/expand.do?elementId=0&frbg=&frbrVersion=2&vl(23971421UI0)=isbn&indx=1&fn=search&gathStatTab=true&dscnt=1&recIds=CLCN_ALEPH_CN001710084&scp.scps=scope%3A%28STE%29%2Cscope%3A%28ST%29%2Cscope%3A%28CLCN_EBOOK%29&displayMode=brief&mode=Basic&vid=ST&renderMode=prefetchXml&ct=display&recIdxs=0&tab=default_tab&srt=rank&doc=CLCN_ALEPH_CN001710084&dum=true&vl(freeText0)=9787010130033&dstmp=1736433043494");

    }

    public void thirdSearch(String url){

        Document doc=null;
        try{
            doc = Jsoup.connect(url).get();
        }catch (Exception e){
            log.error("请求第三次搜索出错"+e.toString());
        }

        Elements fieldsRows = doc.getElementsByClass("EXLAdditionalFieldsRow");
        System.out.println(fieldsRows.size());
        System.out.println(doc.title());


    }
}
